package com.xkdx.caipiao.presistence.hongbaolist;

import java.util.ArrayList;
import java.util.List;

import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.xkdx.caipiao.module.network.AbsModule;

public class HongbaoListModule extends AbsModule {
	public ArrayList<HongbaoListInfo> list;

	@Override
	public void parseData() throws Exception {
		try {
			backJson = (JSONArray) result;
			list = new ArrayList<HongbaoListInfo>();
			for (int i = 0; i < backJson.size(); i++) {
				jsonObj = (JSONObject) backJson.get(i);
				String sortOfAct = jsonObj.getString("Act");
				if (sortOfAct.equals("GetPacketList")) {
					parseJifen(jsonObj.getJSONArray("DetailInfo"));
				}

			}
		} catch (Exception e) {
			throw e;
		}

	}

	private void parseJifen(JSONArray jsonArray) throws Exception {
		try {

			JSONArray array = jsonArray;
			for (int i = 0; i < array.size(); i++) {

				JSONObject obj = jsonArray.getJSONObject(i);
			HongbaoListInfo hongbaoInfo = new HongbaoListInfo();
			hongbaoInfo.setType(obj.getString("type"));
			hongbaoInfo.setName(obj.getString("name"));
			hongbaoInfo.setScore(obj.getString("score"));
			hongbaoInfo.setMoney(obj.getString("money"));
			hongbaoInfo.setDetail(obj.getString("detail"));
			hongbaoInfo.setIcon(obj.getString("icon"));
			hongbaoInfo.setCtime(obj.getString("ctime"));
			hongbaoInfo.setCuser(obj.getString("cuser"));
			hongbaoInfo.setChktime(obj.getString("chktime"));
			hongbaoInfo.setChkuser(obj.getString("chkuser"));
			hongbaoInfo.setStatus(obj.getString("status"));
			hongbaoInfo.setStarttime(obj.getString("starttime"));
			hongbaoInfo.setEndtime(obj.getString("endtime"));
			hongbaoInfo.setRecommend(obj.getString("recommend"));
			hongbaoInfo.setFacevalue(obj.getString("facevalue"));
			hongbaoInfo.setValidity(obj.getString("validity"));
			hongbaoInfo.setId(obj.getString("id"));
			list.add(hongbaoInfo);
			}

		} catch (Exception e) {

			throw e;
		}
	}
}
